//
//  WXPKTPHintFooterView.m
//  MexicoLoan
//
//  Created by wxp on 2025/4/9.
//
//

#import "WXPKTPHintFooterView.h"

@interface WXPKTPHintFooterView ()

@end

@implementation WXPKTPHintFooterView

#pragma mark - lazy
- (UIView *)viewBack{
    if (_viewBack == nil) {
        _viewBack = [UIView new];
        _viewBack.backgroundColor = COLOR_WHITE;
    }
    return _viewBack;
}
- (UILabel *)labelHint
{
    if (_labelHint == nil) {
        _labelHint = [UILabel  new];
        _labelHint.textColor = COLOR_RED;
        _labelHint.fontNum = 12;
        _labelHint.numberOfLines = 0;
        _labelHint.lineSpace = 2;
        _labelHint.hidden = true;
    }
    return  _labelHint;
}

#pragma mark - 初始化
- (instancetype)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        self.widthHeight = XY(SCREEN_WIDTH, 0);
        self.backgroundColor = [UIColor clearColor];
        [self addSubView];
    }
    return self;
}

//添加subview
- (void)addSubView{
    [self addSubview:self.viewBack];
    [self.viewBack addSubview:self.labelHint];
    [self resetViewWithShowHint:false];
}

#pragma mark - 刷新view
- (void)resetViewWithShowHint:(BOOL)isShowHint{
    self.viewBack.width = SCREEN_WIDTH - 2*LEFT_MARDIN;
    
    self.labelHint.hidden = !isShowHint;
    [self.labelHint fitTitle:@"Suba la información siguiente para mejorar su valoración crediticia." variable:self.viewBack.width-2*LEFT_MARDIN];
    self.labelHint.leftTop = XY(LEFT_MARDIN, Ratio(16));
    self.viewBack.height = isShowHint ? (self.labelHint.bottom+Ratio(16)) : (Ratio(20));
    self.viewBack.centerXTop = XY(self.width/2, 0);
    UIBezierPath * maskPath = [UIBezierPath bezierPathWithRoundedRect:self.viewBack.bounds byRoundingCorners:UIRectCornerBottomLeft | UIRectCornerBottomRight cornerRadii:CGSizeMake(16, 16)];
    CAShapeLayer *maskLayer = [[CAShapeLayer alloc] init];
    maskLayer.frame = self.viewBack.bounds;
    maskLayer.path = maskPath.CGPath;
    self.viewBack.layer.mask = maskLayer;
    
    self.height = self.viewBack.bottom+LEFT_MARDIN;
}




@end
